package com.tangzx.builder.abc.string;

public class StringVo {
	public static final int CLASS_NAME = 1;
	public static final int PACKAGE_NAME = 2;
	public static final int PUSH_STRING = 4;
	public static final int SAME_CLASS = 8;
	
	private String value;
	private Boolean canMix = true;
	private String oriValue;

	public long flags = 0x0;
	/**
	 * 是否可以混淆
	 * value 为 "" 时可以混淆
	 * @return
	 */
	public Boolean isCanMix() {
		return (canMix && !isPushString()) || value.equals("");
	}

	/**
	 * 设置不可被混淆标记
	 */
	public void setCanNotMix() {
		this.canMix = false;
	}

	@Override
	public String toString() {
		return value;
	}

	public String getValue() {
		return value;
	}

	public String getOriValue() {
		return oriValue;
	}

	public void setValue(String value) {
		if (oriValue == null)
			oriValue = value;
		this.value = value;
	}

	/**
	 * 如果是pushString，则不可被混淆
	 * @param b
	 */
	public void pushString(boolean b) {
		setKind(PUSH_STRING, b);
	}

	public boolean isPushString() {
		return isKind(PUSH_STRING);
	}
	
	public void setKind(int kind, boolean b) {
		if (b)
			flags |= kind;
		else
			flags ^= kind;
	}
	
	public void setKind(int kind) {
		setKind(kind, true);
	}
	
	public boolean isKind(int kind) {
		return (flags & kind) == kind;
	}
}
